Page({
  data: {
    type: 2,
    money: '',
    cycle: '24',
    repayment: '',
    items: [
      { value: '24', name: '24', checked: true},
      { value: '36', name: '36' },
    ],
    purposeArray: ['网上购物', '生活消费', '生活缴费'],
    purpose: 0
  },
  purposePickerChange: function (e) {
    this.setData({
      purpose: e.detail.value
    })
  },
  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value);
    this.data.cycle = e.detail.value;
    var items = this.data.items;
    for (var i = 0, len = items.length; i < len; ++i) {
      items[i].checked = items[i].value == e.detail.value;
    }

    this.setData({
      items: items
    });
  }, 
  moneyChange: function (e) {
    this.data.money = e.detail.value
  },
  repaymentChange: function (e) {
    this.data.repayment = e.detail.value
  },
  perfectInfo: function () {
    if (this.data.money == '') {
      wx.showModal({
        title: '提示',
        content: '请输入借款金额!',
        showCancel: false,
        success: function (res) { }
      });
      return false;
    }
    if (this.data.repayment == '') {
      wx.showModal({
        title: '提示',
        content: '请输入还款金额!',
        showCancel: false,
        success: function (res) { }
      });
      return false;
    }

    var purposeText = this.data.purposeArray[this.data.purpose];
    //完善信息
    wx.navigateTo({ url: "perfectInfo?type=" + this.data.type + "&money=" + this.data.money + "&cycle=" + this.data.cycle + "&purpose=" + purposeText + "&repayment=" + this.data.repayment })
  }
})